'use strict';

/**
 * Created by zhenguang.zhu on 2014/12/11.
 */
angular.module('common').controller('MenuCtrl', ['$location', '$window', '$scope', '$rootScope', '$routeParams', function ($location, $window, $scope, $rootScope, $routeParams) {
    $scope.isActive = function (routes) {
        var active = false;
        angular.forEach(routes, function (r) {
            var rex = new RegExp('^/\\d+' + r);
            if (rex.test($location.path())) {
                active = true;
                return;
            }
        });
        return active;
    };

    $scope.goToShare = function () {
        $window.location.href = $rootScope.thirdPartyPaths.share + $routeParams.userId;
    };

    $scope.goToCollect = function () {
        $window.location.href = $rootScope.thirdPartyPaths.collect + $routeParams.userId;
    };

    $scope.goToGroup = function () {
        $window.location.href = $rootScope.thirdPartyPaths.group + $routeParams.userId;
    };

    $scope.goToCourse = function () {
        $window.location.href = $rootScope.thirdPartyPaths.course + $routeParams.userId;
    };

    $scope.goToMedal = function () {
        $window.location.href = $rootScope.thirdPartyPaths.medal + $routeParams.userId;
    };
}]);
